package com.cw.jeeyt.dao.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.dao.intf.system.SystemCityDao;
import com.cw.jeeyt.dao.mapper.system.SystemCityMapper;
import com.cw.jeeyt.dao.model.system.SystemCityDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * 城市信息 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class SystemCityDaoImpl implements SystemCityDao {
    @Autowired
    private SystemCityMapper systemCityMapper;
    /**
     * 查询所有城市信息
     *
     * @return 城市信息集合
     */
    @Override
    public List<SystemCityDo> querySystemCityList() {
        return systemCityMapper.querySystemCityList();
    }

    /**
     * 删除城市信息
     *
     * @param systemCity
     */
    @Override
    public void deleteSystemCity(SystemCityDo systemCity) {
        systemCityMapper.deleteSystemCity(systemCity);
    }

    /**
     * 修改城市信息
     *
     * @param systemCity
     */
    @Override
    public void updateSystemCity(SystemCityDo systemCity) {
        systemCityMapper.updateSystemCity(systemCity);
    }

    /**
     * 根据主键查询城市信息
     *
     * @param id 主键id
     * @return SystemCity
     */
    @Override
    public SystemCityDo getSystemCityById(String id) {
        return systemCityMapper.getSystemCityById(id);
    }

    /**
     * 新增城市信息
     *
     * @param systemCity
     * @return 整数
     */
    @Override
    public Integer insertSystemCity(SystemCityDo systemCity) {
        return systemCityMapper.insertSystemCity(systemCity);
    }

    /**
     * 分页查询城市信息
     *
     * @param systemCity 查询条件
     * @param startNum 开始条数
     * @param pageSize 每页长度
     * @return SystemCity集合
     */
    @Override
    public PageInfo<SystemCityDo> queryByPage(SystemCityDo systemCity, Integer startNum, Integer pageSize)
    {
        PageHelper.startPage(PageUtil.calPageNum(startNum, pageSize), pageSize);
        return new PageInfo<>(systemCityMapper.queryByPage(systemCity));
    }

    /**
     * 根据省份id加载城市信息
     *
     * @param provinceId 省份id
     * @return
     * @throws Exception
     */
    @Override
    public List<SystemCityDo> loadSystemCityByProvinceId(String provinceId) {
        return systemCityMapper.loadSystemCityByProvinceId(provinceId);
    }

}
